package model.altarica_fields;

import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import math.Expression;

public class Trans {

    private Expression guard;
    private List<Event> e;
    private final List<UpdateExpression> u;

    public Trans(Expression guard, List<Event> e, List<UpdateExpression> u) {

        this.guard = guard;

        this.e = new LinkedList<Event>();

        this.e = e;

        this.u = u;

    }

    public Expression getGuard() {

        return this.guard;
    }

    public Collection<Event> getEvent() {

        return Collections.unmodifiableList(this.e);
    }

    public void addEvent(Event e) {

        this.e.add(e);
    }

    public void setEvents(List<Event> e) {

        this.e = e;
    }

    public Collection<UpdateExpression> getUpdates() {

        return Collections.unmodifiableCollection(this.u);
    }

    @Override
    public String toString() {

        String str = guard + " |- ";


        for (Event ev : e) {

            str += ev.getId() + ", ";
        }

        str = str.substring(0, str.length() - 2);

        str += " -> ";

        if (u.isEmpty() == false) {

            for (UpdateExpression up : u) {

                str += up + ", ";
            }

            str = str.substring(0, str.length() - 2);
        }


        return str;
    }
}
